package cat.joronya.supermanager.service;

import android.os.Message;
import android.util.Log;
import cat.joronya.supermanager.Supermanager;

/**
 * Login Handler which handles three different status on abstract methods:
 * -closedWeb method to handle CLOSED_STATUS
 * -openWebNoChanges method to handle OPEN_NO_CHANGES_STATUS
 * -openWeb method to handle OPEN_STATUS
 * 
 * @author pol
 *
 */
public abstract class LoginHandler extends BaseHandler 
{
	@Override 
    public void handleMessage(Message msg)
    { 
        //get data from msg 
        status = msg.getData().getInt(Supermanager.STATUS_MESSAGE);
        Log.d(TAG, "LoginHandler received status: "+status);
        
        if( status == Supermanager.CLOSED_STATUS )
        {
        	closedWeb();
        }
        else if( status == Supermanager.OPEN_NO_CHANGES_STATUS )
        {
        	openWebNoChanges();
        }
        else if( status == Supermanager.OPEN_STATUS )
        {
        	openWeb();
        }
        
        super.handleMessage(msg);
    }
	
	/**
	 * Executed when received CLOSED_STATUS
	 */
	public abstract void closedWeb();
	
	/**
	 * Executed when received OPEN_NO_CHANGES_STATUS
	 */
	public abstract void openWebNoChanges();
	
	/**
	 * Executed when received OPEN_STATUS
	 */
	public abstract void openWeb();
}
